Skip to content

[ana6, com8]: Add ana6Optimisation Module, apply changes in com8MoTPSA#1245

Open
RolandFischbacher wants to merge 5 commits intomasterfrom
RF_com8MoTPSA
Open

[ana6, com8]: Add ana6Optimisation Module, apply changes in com8MoTPSA#1245
RolandFischbacher wants to merge 5 commits intomasterfrom
RF_com8MoTPSA

Conversation

@RolandFischbacher
Copy link
Contributor

This PR introduces a new optimisation module ana6Optimisation for com8MoTPSA and updates the simulation workflow.


The module ana6Optimisation includes:

  • Calculation of combined loss function (runout + tversky)
  • Morris sensitivity analysis for parameter ranking
  • Sequential and non-sequential surrogate based optimisation routines

New files in ana6Opitmisaton:

  • runMorrisSA.py (configuration: runMorrisSACfg.ini)
  • runPlotMorrisConvergence.py (uses runMorrisSACfg.ini)
  • runOptimisation.py (configuration: runOptimisationCfg.ini)
  • optimisationUtils.py
  • README_ana6.md (contains usage instructions)

New file in out3Plot:

  • outAna6Plots.py

Changed workflow of runing com8MoTPSA:

  • Check prior if simulation is run already
  • Process in chunks not all simulations at once

@RolandFischbacher RolandFischbacher self-assigned this Feb 23, 2026
@RolandFischbacher RolandFischbacher added the enhancement New feature or request label Feb 23, 2026
@qltysh
Copy link
Contributor

qltysh bot commented Feb 23, 2026

❌ 3 blocking issues (4 total)

Tool Category Rule Count
black Style Incorrect formatting, autoformat by running qlty fmt. 3
qlty Structure Function with high complexity (count = 17): readConfigurationInfoFromDone 1

@qltysh one-click actions:

  • Auto-fix formatting (qlty fmt && git push)

# 4) Plot
x = np.arange(len(df))
fig, ax = plt.subplots(figsize=(12, 6))
bars = ax.bar(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Local variable bars is assigned to but never used [ruff:F841]

Suggested change
bars = ax.bar(
ax.bar(

@fso42 fso42 added this to the Version 2.0 milestone Feb 23, 2026
@fso42 fso42 changed the title [ana6Opitmisation], [com8MoTPSA]: Add ana6Optimisation Module, apply changes in com8MoTPSA [ana6, com8]: Add ana6Optimisation Module, apply changes in com8MoTPSA Feb 24, 2026
@fso42 fso42 assigned fso42 and unassigned RolandFischbacher Feb 24, 2026
Squash of 20 commits from RF_com8MoTPSA branch including:
- com8MoTPSA workflow improvements (chunked multiprocessing, path handling)
- Bayesian optimisation integration (ana6Optimisation module)
- Morris sensitivity analysis scripts
- AIMEC runout reference implementation
- probAna pickle saving and bounds
- Plotting and config improvements
@qltysh
Copy link
Contributor

qltysh bot commented Feb 24, 2026

Qlty

Coverage Impact

⬇️ Merging this pull request will decrease total coverage on master by 0.19%.

Modified Components (1)

RatingComponent% Diff
Coverage rating: C Coverage rating: C
com1DFA

Modified Files with Diff Coverage (2)

RatingFile% DiffUncovered Line #s
Coverage rating: F Coverage rating: F
avaframe/com8MoTPSA/com8MoTPSA.py0.0%21-182
Coverage rating: A Coverage rating: A
avaframe/in3Utils/cfgUtils.py71.4%995, 1016
Total10.0%
🤖 Increase coverage with AI coding...

In the `RF_com8MoTPSA` branch, add test coverage for this new code:

- `avaframe/com8MoTPSA/com8MoTPSA.py` -- Line 21-182
- `avaframe/in3Utils/cfgUtils.py` -- Lines 995 and 1016

🚦 See full report on Qlty Cloud »

🛟 Help
  • Diff Coverage: Coverage for added or modified lines of code (excludes deleted files). Learn more.

  • Total Coverage: Coverage for the whole repository, calculated as the sum of all File Coverage. Learn more.

  • File Coverage: Covered Lines divided by Covered Lines plus Missed Lines. (Excludes non-executable lines including blank lines and comments.)

    • Indirect Changes: Changes to File Coverage for files that were not modified in this PR. Learn more.

@fso42 fso42 assigned RolandFischbacher and unassigned fso42 Feb 24, 2026
- Add bounds to paramValuesD in createSamplesWithVariation (StandardParameters)
- Add writing of visualisation scenario and sampling method to com8MoTPSACfg.ini
@@ -0,0 +1,886 @@
import numpy as np
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A general note for this file: use log.info instead of prints for user info

return xBest, xBestDict, np.max(ei), np.max(lcb)


def runCom8MoTPSA(avalancheDir, xBestDict, cfgMain, i=0, optimisationType=None):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this could be solved differently, as it duplicates code that might be changed. Investigate if a direct call with updated cfgs would be better. Let me now if you need help

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implemented a direct call of com8MoTPSAMain with updated cfgs (writeCfgFiles in optimisationUtils.py)

Comment on lines +87 to +95
if 'VISUALISATION' in config.sections():
# config is inifile
index = config['VISUALISATION']['scenario']

if 'VISUALISATION' in config.sections():
# config is inifile
index = config['VISUALISATION']['scenario']
if 'sampleMethod' in config['VISUALISATION']:
sampleMethod = config['VISUALISATION']['sampleMethod']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if any .ini file in the config directory lacks a VISUALISATION section, the variables index and sampleMethod are never assigned, but they are unconditionally appended on lines 107-108. On the first such file, this raises UnboundLocalError. Even if subsequent iterations reuse a stale value from a previous file, the data would be silently wrong.

# config is inifile
index = config['VISUALISATION']['scenario']

if 'VISUALISATION' in config.sections():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the duplicate if? Copy/Paste error?

if modName.lower() in ["com1dfa", "com5snowslide", "com6rockavalanche", 'com8motpsa']:
cfgStart["VISUALISATION"]["scenario"] = str(count1)
cfgStart["INPUT"]["thFromIni"] = paramValuesD["thFromIni"]
cfgStart["VISUALISATION"]["sampleMethod"] = cfg['PROBRUN']['sampleMethod']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new line cfgStart["VISUALISATION"]["sampleMethod"] = cfg['PROBRUN']['sampleMethod'] reads sampleMethod from cfg['PROBRUN'].

However, probAnaCfg.ini has sampleMethod under [PROBRUN] only when probAna is the caller. If createCfgFiles is called from a different path where cfg doesn't have PROBRUN.sampleMethod, this will raise KeyError. The code also assumes VISUALISATION section exists in cfgStart for com8MoTPSA — while the new com8MoTPSACfg.ini does add it, there's no sampleMethod default there, making the flow dependent on the caller always providing this key.

mean_sigma = topNData["sigma"].mean()
std_sigma = topNData["sigma"].std()

print(f"\n🔍 Mittelwerte ± Std (Top {N}):")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as mentioned elsewhere: log.info AND english text please

@OpenNHM OpenNHM deleted a comment from qltysh bot Feb 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants